<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>API接口平台</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">

    <link rel="stylesheet" href="/static/layui/css/layui.css">
    <link rel="stylesheet" href="/static/css/apidoc.css?t={{.ts}}" media="all">
    <link rel="stylesheet" href="/static/font-awesome/css/font-awesome.min.css" media="all">
</head>
<body style="overflow-x:hidden">

<div class="layui-header">
    <div style="float: left;background: #393D49;width:20%;height: 60px;line-height: 60px;">
        <a class="" href="/" style="margin-left: 20px;">
            <img src="/static/img/logo.png" alt="ppgo_admin" style="width: 100px;">
        </a>
    </div>
    <div style="float: right;width: 80%;">
        <ul class="layui-nav" >
            <li class="layui-nav-item layui-this">
                <a href="###">文档</a>
            </li>
            <li class="layui-nav-item ">
                <a href="/home">后台<!-- <span class="layui-badge-dot"></span> --></a>
            </li>
        </ul>
    </div>

</div>

<div class="layui-main layui-row" style="width: 100%;">
    <div class="site-tree layui-col-md2 layui-hide-xs">

        <ul class="layui-tree" style="height: 18px; margin: 10px 13px 0 0;padding-left: 10px;margin-bottom: 20px;">
            <li><h2>基础说明</h2></li>
            <ul>

                <li class="site-tree-noicon">
                    <a href="/keyword/list" data-type="env" data-id="{{.groupId}}">
                        <cite>词库列表</cite>
                    </a>
                </li>

                <li class="site-tree-noicon">
                    <a href="/keyword/listall" data-type="code" data-id="{{.groupId}}">
                        <cite>翻译日志</cite>
                    </a>
                </li>
            </ul>

        </ul>
        <div style="clear:both"></div>
        <div class="copyrights">power by Flash API</div>
    </div>

    <div class="site-content layui-col-md10">
        <div class="site-content-header"><i class="fa fa-bars" aria-hidden="true" id="taggle"></i>&nbsp;&nbsp;<span id="content-title">词库系统</span> </div>
        <div id="api-main">
            <table class="layui-hide" id="table_list" lay-filter="table_filter">
            </table>

            <script type="text/html" id="bar">
                <!--  <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a> -->
                <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
                <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="status">启|禁</a>

            </script>
        </div>
    </div>

</div>


<script src="/static/layui/layui.js?s=36"></script>

<script>
    layui.use(['table','form','element'], function(){
        var table = layui.table;
        var form = layui.form;
        var element = layui.element;
        var $ = layui.jquery;
        var windowWidth    = $(document.body).outerWidth(true);
        var windowHeight   = $(window).height();
        var contentHeight = windowHeight-$('.layui-header').outerHeight(true);
        $("#api-main").height(contentHeight-$('.site-content-header').outerHeight(true));
        $(".site-tree").height(contentHeight);
        //方法级渲染
        table.render({
            elem: '#table_list'
            ,url: '/keyword/tableaddrs'
            ,cols: [[
                // {checkbox: true, fixed: true},
                {field:'id', title: 'ID', align:'center',sort: true, width:150}//fixed
                ,{field:'key_name',title: 'key'}
                ,{field:'cn', title: '中文'}
                ,{field:'en', title: '英语'}
                ,{field:'th',title: '泰语', align:'center',
                    //toolbar: '#bar'
                }
            ]]
            ,id: 'listReload'
            ,page: true
            ,height: "full-130"
            ,limit :1000
        });

        var $ = layui.$, active = {
            reload: function(){
                table.reload('listReload', {
                    where: {
                        envName: $('#envName').val(),
                    }
                });
            }
        };

        //监听工具条
        table.on('tool(table_filter)', function(obj){
            var data = obj.data;
            if(obj.event === 'detail'){
                layer.msg('ID：'+ data.id + ' 的查看操作');
            } else if(obj.event === 'del'){
                layer.confirm('真的删除【'+data.env_name+'】么', function(index){
                    var jsData = {'id':data.id}
                    $.post('{{urlfor "EnvController.AjaxDel"}}', jsData, function (out) {
                        if (out.flag == 0) {
                            layer.alert('删除成功了', {icon: 1},function(index){
                                layer.close(index);
                                window.location.reload();
                            });
                        } else {
                            layer.msg(out.message)
                        }
                    }, "json");
                    obj.del();
                    layer.close(index);
                });
            } else if(obj.event === 'edit'){
                console.log(data.id);
                //window.location.href="/env/edit?id="+data.id
            }
        });

        $('.demoTable .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });

</script>
</body>
</html>